package com.class05;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.function.Consumer;
import java.util.stream.Stream;

@WebServlet("/b")
public class ServletB extends ServletA{
    protected void service(HttpServletRequest req,
                           HttpServletResponse resp) throws ServletException, IOException {
        Cookie[] cookies = req.getCookies();
//        for (Cookie cookie : cookies) {
//            System.out.println(cookie.getName()+":"+cookie.getValue());
//        }
//
        Arrays.stream(cookies).forEach(cookie
                -> System.out.println(cookie.getName()
                +":"+cookie.getValue()));

//        Stream<Cookie> stream = Arrays.stream(cookies);
//        stream.forEach( new Consumer<Cookie>(){
//            public void accept(Cookie cookie) {
//                System.out.println(cookie.getName()+":"+cookie.getValue());
//            }
//        });


    }
}
